<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin;
use App\Http\Middleware\JwtMiddleware;

Route::get('/', function () {
    return view('welcome');
});

Route::prefix('api')->group(function () {
    Route::post('/auth/init', [Admin\AuthController::class, 'init']);
    Route::post('/auth/login', [Admin\AuthController::class, 'login']);

    Route::middleware([JwtMiddleware::class])->group(function () {
        Route::post('/logout', [Admin\AuthController::class, 'logout']);
        Route::get('/auth/info', [Admin\AuthController::class, 'info']);
        Route::resource('/user', Admin\UserController::class);
        Route::delete('/user', [Admin\UserController::class, 'batchDelete']);

        Route::get('/menu/permission', [Admin\MenuController::class, 'permission']);
        Route::get('/menu/flat', [Admin\MenuController::class, 'flat']);
        Route::resource('/menu', Admin\MenuController::class);

        Route::get('/role/all', [Admin\RoleController::class, 'all']);
        Route::resource('/role', Admin\RoleController::class);
        Route::delete('/role', [Admin\RoleController::class, 'batchDelete']);
    });
});
